<template>
  <div :class="['board-space-wrap', `vbs-${config.direction}`]"
       :style="{width: config.direction === 'TD' ? '100%' : `${config.spaceWH}px`,
       height: config.direction === 'TD' ? `${config.spaceWH}px` : '100%'}"
       :data-id="config.id"
       ref="vbSpaceWrap">
    <div :class="['vbs-control-wrap','hoverStyle']" v-if="!isPreview">
      <div :class="['vbs-c-line',`vbs-c-l-${config.direction}`]"></div>
      <div :class="['vbs-c-button',`vbs-c-b-${config.direction}`]" @mousedown="dragMousedown"
           @mouseup="dragMouseup"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'space',
  props: {
    config: {
      type: Object,
      default: () => {
      }
    },
    isPreview: {
      type: Boolean,
      default: () => false
    }//全屏/预览
  },
  methods: {
    //拖拽分割线
    dragMousedown() {
      this.$emit('dragMousedown', 'space', this.config)
    },
    dragMouseup() {
      this.$emit('dragMouseup', 'space', this.config)
    }
  }
}
</script>

<style scoped lang="scss">
@import "./styles";

.board-space-wrap {
  position: relative;

  .vbs-control-wrap {
    width: 100%;
    height: 100%;
    position: absolute;
    opacity: 0;
    transition: all .3s;

    .vbs-c-line {
      position: absolute;
    }

    /* 横向时 线 */
    .vbs-c-l-TD {
      height: 1px;
      width: 100%;
      background-color: #036EFF;
      position: absolute;
      top: calc(50% - 0.5px);
      left: 0;
    }

    /* 纵向时 线 */
    .vbs-c-l-LD {
      height: 100%;
      width: 1px;
      background-color: #036EFF;
      position: absolute;
      left: calc(50% - 0.5px);
      top: 0;
    }

    .vbs-c-button {
      position: absolute;

    }

    /* 横向时 按钮 */
    .vbs-c-b-TD {
      background-image: url("../../../../../assets/images/button.png");
      width: $control-button-short;
      height: $control-button-long;
      transform: rotate(90deg);
      top: calc(50% - #{$control-button-long} / 2);
      left: calc(50% - #{$control-button-short} / 2);
      cursor: ns-resize;
      border-radius: 5px;
    }

    /* 纵向时 按钮 */
    .vbs-c-b-LD {
      height: $control-button-long;
      width: $control-button-short;
      background-image: url("../../../../../assets/images/button.png");
      top: calc(50% - #{$control-button-long} / 2);
      left: calc(50% - #{$control-button-short} / 2);
      cursor: ew-resize;
      border-radius: 5px;
    }
  }

  .hoverStyle {
    &:hover {
      opacity: 1;
    }
  }

  /*!* 横向 *!
  .vbs-TD {
    width: 100%;
    height: $board-space;
  }

  !* 纵向 *!
  .vbs-LD {
    width: $board-space;
    height: 100%;
  }*/
}
</style>
